package Presum;

/**
 * @Classname 连续的子数组和523
 * @Description TODO
 * @Date 2023/2/15 22:32
 * @Created by xjl
 */
public class 连续的子数组和523 {

    public boolean checkSubarraySum(int[] nums, int k) {
        int n=nums.length;
        if (n<2){
            return false;
        }
        int[] pre=new int[n+1];
        for (int i=1;i<pre.length;i++){
            pre[i]=pre[i-1]+nums[i-1];
        }
        for (int i=1;i<pre.length;i++){
            for (int j=i+2;j<pre.length;j++){
                if ((pre[j]-pre[i])%k==0){
                    return true;
                }
            }
        }
        return false;
    }
}
